"""扫描任务Service"""
from typing import List, Optional
from sqlalchemy.orm import Session
from app.repositories.scan_task_repository import ScanTaskRepository
from app.models.scan_task import ScanTask


class ScanTaskService:
    """扫描任务业务逻辑层"""

    def __init__(self, db: Session):
        self.repository = ScanTaskRepository(db)

    def get_all(self, skip: int = 0, limit: int = 100) -> List[ScanTask]:
        """获取所有扫描任务"""
        return self.repository.get_all(skip=skip, limit=limit)

    def get_by_id(self, task_id: int) -> Optional[ScanTask]:
        """根据ID获取任务"""
        return self.repository.get(task_id)

    def get_by_task_type(self, task_type: str) -> Optional[ScanTask]:
        """根据任务类型获取任务"""
        return self.repository.get_by_task_type(task_type)

    def get_enabled_tasks(self) -> List[ScanTask]:
        """获取所有启用的任务"""
        return self.repository.get_enabled_tasks()

